ECHO OFF

:: SETTINGS

:: The drive of both the MySQL Files & Aegir (Yes they must be on the same drive)
E:
:: The bin directory of the MySQL Files
cd E:\Program Files\Maria DB\bin
:: The username for the Aegir Database
SET Username=root
:: The password for the Aegir Database
SET Password=badpass
:: The host of the Database
SET Host=localhost
:: The directory where the Aegir folder is (it must be named Aegir)
SET Directory=E:\

ECHO Welcome to the local test setup Tool

SET /p NewData="Grab DB (y/n)?"
SET /p DropDB="Drop Local DB (y/n)?"
SET /p CreateDB="Create Local DB (y/n)?"

ECHO Starting work...
IF %NewData%==y (
	ECHO Grabbing Tables and Data
	mysqldump -u %Username% -p%Password% -h %Host% -d --routines aegir>%Directory%Aegir\DBFiles\aegir.sql
	mysqldump -u %Username% -p%Password% -h %Host% aegir settings>%Directory%Aegir\DBFiles\aegirData.sql
)

IF %DropDB%==y (
	ECHO Dropping Test DB
	mysqladmin -u %Username% -p%Password% -h %Host% -f drop aegir
)

IF %CreateDB%==y (
	ECHO Creating Test DB
	mysql -u %Username% -p%Password% -h %Host% -e "CREATE DATABASE aegir"

	ECHO Loading Tables and Data
	mysql -u %Username% -p%Password% -h %Host% aegir < %Directory%Aegir\DBFiles\aegir.sql
	mysql -u %Username% -p%Password% -h %Host% aegir < %Directory%Aegir\DBFiles\aegirData.sql
)

ECHO Exiting
PAUSE